<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>订单详情</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Arial', sans-serif;
        }

        body {
            background-color: #f4f4f4;
            color: #333;
            line-height: 1.6;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
        }

        header {
            background-color: #f2c57f;
            width: 100%;
            padding: 20px 0;
            text-align: center;
            margin-bottom: 30px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }

        header h1 {
            color: #fff;
            font-size: 36px;
            font-weight: bold;
        }

        .order-card {
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
            max-width: 400px;
            width: 100%;
            padding: 20px;
            text-align: center;
            transition: box-shadow 0.3s ease-in-out;
        }

        .order-card:hover {
            box-shadow: 0 6px 15px rgba(0,0,0,0.15);
        }

        .order-card img {
            width: 100%;
            height: 220px;
            object-fit: cover;
            border-radius: 6px;
            margin-bottom: 20px;
        }

        .order-info {
            text-align: left;
            font-size: 18px;
            color: #444;
        }

        .order-info p {
            margin-bottom: 12px;
            line-height: 1.4;
        }

        .order-info strong {
            color: #e74c3c;
        }

        footer {
            margin-top: 40px;
            width: 100%;
            text-align: center;
            padding: 15px 0;
            background-color: #333;
            color: #fff;
            font-size: 14px;
            user-select: none;
        }

        @media (max-width: 480px) {
            .order-card {
                max-width: 100%;
                padding: 15px;
            }
        }
    </style>
</head>
<body>
<header>
    <h1>订单详情</h1>
</header>

<div id="app">
    <div class="order-card" v-if="myorder.orderId">
        <img :src="myorder.dishImg" alt="商品图片" />
        <div class="order-info">
            <p><strong>订单编号：</strong> {{ myorder.orderNumber }}</p>
            <p><strong>商品名称：</strong> {{ myorder.dishName }}</p>
            <p><strong>商品原价：</strong> ¥{{ myorder.dishPrice }}</p>
            <p><strong>优惠价格：</strong> ¥{{ myorder.couponPrice || 0 }}</p>
            <p><strong>订单价格：</strong> ¥{{ myorder.orderPrice }}</p>
            <p><strong>下单时间：</strong> {{ myorder.orderCreateTime }}</p>
        </div>
    </div>
</div>

<footer>
    &copy;2010-2025 0090🍔 | ゼロゼロきゅうゼロ Corporation. All rights reserved
</footer>

<script>
    new Vue({
        el:"#app",
        data:{
            myorder:{
                orderId:"",
                orderNumber:"",
                dishId:"",
                dishName:"",
                dishImg:"",
                dishPrice:"",
                orderPrice:"",
                couponName:"",
                couponPrice:"",
                mycouponId:"",
                orderCreateTime:""
            }
        },
        mounted(){
            this.getByOrderId()
        },

        methods:{
            getByOrderId(){
                const urlParams = new URLSearchParams(window.location.search);
                const id = urlParams.get("id");
                axios.get("myorder/" + id).then(response => {
                    if(response.data.code == 200) {
                        this.myorder = response.data.data;
                    } else {
                        alert("订单信息加载失败");
                    }
                }).catch(error => {
                    console.error(error);
                    alert("请求出错");
                });
            },
        }
    })
</script>
</body>
</html>
